<pre class='metadata'>
Title: CSS Box Sizing Module Level 3
Shortname: css-sizing
Level: 3
Status: ED
Work Status: Refining
Group: csswg
ED: https://drafts.csswg.org/css-sizing-3/
TR: https://www.w3.org/TR/css-sizing-3/
Issue Tracking: CSSWG GitHub https://github.com/w3c/csswg-drafts/issues
Editor: Tab Atkins, Google, http://xanthir.com/contact/, w3cid 42199
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Previous version: https://www.w3.org/TR/2021/WD-css-sizing-3-20210317/
Previous version: https://www.w3.org/TR/2020/WD-css-sizing-3-20201218/
Previous version: https://www.w3.org/TR/2020/WD-css-sizing-3-20201023/
Previous version: https://www.w3.org/TR/2019/WD-css-sizing-3-20190522/
Previous version: https://www.w3.org/TR/2018/WD-css-sizing-3-20180304/
Previous version: https://www.w3.org/TR/2017/WD-css-sizing-3-20170207/
Abstract: This module extends the CSS sizing properties with keywords that represent content-based "intrinsic" sizes and context-based "extrinsic" sizes, allowing CSS to more easily describe boxes that fit their content or fit into a particular layout context.
Ignored Terms: content box, border box, non-replaced
At Risk: Additions to 'column-width'
</pre>

<pre class='link-defaults'>
spec:css-align-3; type:value; text:stretch; for:align-self
spec:css-borders-4; type:property; text:border
spec:css-display-3;
	type:dfn; text:box
	type:property; text:display
spec:css-page-3; type:at-rule; text:@page
spec:css2; type: property
	text: min-width
	text: min-height
	text: max-width
	text: max-height
</pre>

<!-- Notes on stuff to do... [copy/pasted from etherpad, probably out-of-date, evaluate later]
  Swap definition of preferred size in for max-content.
  Define current max-content as super-max-content.
  Mark an issue about whether it's a necessary concept;
  I'm unsure, but I think it will show up in orthogonal flow sizing.
-->

<h2 id="intro">
Introduction</h2>

	<p><em>This section is not normative.</em>

	<p>
		CSS layout has several different concepts of automatic sizing that are used in various layout calculations.
		This section defines some more precise terminology
		to help connect the layout behaviors of this spec to the calculations used in other modules,
		and some new keywords for the 'width' and 'height' properties
		to allow authors to assign elements the dimensions resulting from these size calculations.


		Issue: This spec needs illustrations! See <a href="https://github.com/w3c/csswg-drafts/issues/1938">issue</a>.

<h3 id="placement">
Module interactions</h3>

	<p>This module extends the 'width', 'height', 'min-width', 'min-height', 'max-width', 'max-height', and 'column-width'
	features defined in [[!CSS2]] chapter 10 and in [[!CSS3COL]]

	<p>The definition of the 'box-sizing' property in this module supersedes the one in [[CSS-UI-3]].

<h3 id="values">
Value Definitions</h3>

	This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
	using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
	Value types not defined in this specification are defined in CSS Values &amp; Units [[!CSS-VALUES-3]].
	Combination with other CSS modules may expand the definitions of these value types.

	In addition to the property-specific values listed in their definitions,
	all properties defined in this specification
	also accept the <a>CSS-wide keywords</a> as their property value.
	For readability they have not been repeated explicitly.

<!--
████████ ████████ ████████  ██     ██  ██████
   ██    ██       ██     ██ ███   ███ ██    ██
   ██    ██       ██     ██ ████ ████ ██
   ██    ██████   ████████  ██ ███ ██  ██████
   ██    ██       ██   ██   ██     ██       ██
   ██    ██       ██    ██  ██     ██ ██    ██
   ██    ████████ ██     ██ ██     ██  ██████
-->

<h2 id="terms">
Terminology</h2>

	Some key terminology related to coordinate axises and dimensions
	is defined in [[css-writing-modes-3#abstract-box]].

	<dl export>
		<dt><dfn>size</dfn>
		<dd>
			A one- or two-dimensional measurement:
			a <a>block size</a> and/or <a>inline size</a>;
			alternatively a [=width=] and/or [=height=].

			<figure>
				<img style="max-width: 49%;" width=420 height=240 src="images/sizing-ltr-tb.svg"
				     alt="In left-to-right, top-to-bottom horizontal English,
				          the horizontal width and inline size are synonymous,
				          and vertical height and block size are synonymous."><!--
				--><img style="max-width: 49%;" width=420 height=240 src="images/sizing-ttb-rl.svg"
				      alt="In top-to-bottom, right-to-left vertical Japanese,
				           the horizontal width and block size are synonymous,
				           and vertical height and inline size are synonymous.">
				<figcaption>Whether the <a>width</a> or <a>height</a> corresponds
				to an <a>inline size</a> or <a>block size</a> depends on the <a>writing mode</a>.</figcaption>
			</figure>

		<dt><dfn lt="inner size|inner width|inner height|inner block size|inner inline size">inner size</dfn>
		<dd>
			The <a href="https://www.w3.org/TR/css2/box.html#box-dimensions">content-box</a> [=size=] of a <a>box</a>.

			<figure>
				<img src="images/inner-size.svg" width=420 height=270 alt="">
				<figcaption>Inner size</figcaption>
			</figure>

		<dt><dfn lt="outer size|outer width|outer height|outer block size|outer inline size">outer size</dfn>
		<dd>
			The <a href="https://www.w3.org/TR/css2/box.html#box-dimensions">margin-box</a> [=size=] of a <a>box</a>.

			<figure>
				<img src="images/outer-size.svg" width=420 height=270 alt="">
				<figcaption>Outer size</figcaption>
			</figure>

		<dt><dfn id="definite" lt="definite|definite size">definite size</dfn>
		<dd>
			A size that can be determined without performing layout;
			that is, a <<length>>,
			a measure of text (without consideration of line-wrapping),
			a size of the <a>initial containing block</a>,
			or a <<percentage>> or other formula
			(such the <a href="https://www.w3.org/TR/CSS2/visudet.html#blockwidth">“stretch-fit” sizing of non-replaced blocks</a> [[CSS2]])
			that is resolved solely against <a>definite</a> sizes.

			Additionally, the size of the <a>containing block</a> of an absolutely positioned element is always <a>definite</a>
			with respect to that element.

		<dt><dfn id="indefinite" lt="indefinite|indefinite size">indefinite size</dfn>
		<dd>
			A size that is not <a>definite</a>.
			<a>Indefinite</a> <a>available space</a> is essentially infinite.

			Note: [=intrinsic sizing=] keywords such as ''width/max-content'' are indefinite,
			even if they can be determined without laying out the children
			e.g. due to [=size containment=] or lack of children.

		<dt><dfn id="available" local-lt="available" lt="available space|available inline space|available block space">available space</dfn>
		<dd>
			A size representing the space into which a box is laid out,
			as determined by
			the rules of the formatting context in which it participates.
			The space available to a box is usually
			either a measurement of its <a>containing block</a> (if that is <a>definite</a>)
			or an infinite size (when it is <a>indefinite</a>).
			<a>Available space</a> can alternatively be either a
			<a>min-content constraint</a> or
			a <a>max-content constraint</a>,
			which forces boxes laid into it to be laid out under that constraint.

<!--
			<p>
				The space <a>available</a> to a box is determined by the formatting context in which it participates.
				In block, table, and inline formatting contexts [[!CSS2]],
				the <a>available space</a> is infinite in the block-axis dimension.
				<span class="issue">What, exactly, is the available space in the inline axis??? What about other formatting models?</span>
-->

		<dt><dfn>stretch fit</dfn>
		<dd>
			The <a>stretch fit</a> into a given size
			is that size,
			minus the box's computed margins (not collapsed, treating ''margin/auto'' as zero),
			border, and padding in the given dimension
			(such that the outer size is a perfect fit),
			and flooring at zero
			(so that the inner size is not negative).

			<p class='note'>
				Note: This is the formula used to calculate the ''width/auto'' widths
				of non-replaced blocks in normal flow in <a href="https://www.w3.org/TR/CSS2/visudet.html#blockwidth">CSS2.1§10.3.3</a>.

		<dt><dfn lt="fallback|fallback size">fallback size</dfn>
		<dd>
			Some sizing algorithms do not work well with an infinite size.
			In these cases, the <a>fallback size</a> is used instead.
			Unless otherwise specified,
			this is the size of the <a>initial containing block</a>.
	</dl>

<h3 id='auto-box-sizes'>
Auto Box Sizes</h3>

	There are four types of automatically-determined sizes in CSS
	(sizes resulting from ''width/auto'' sizing rules, depending on context):

	<dl export>
		<dt><dfn>stretch-fit size</dfn>
		<dt><dfn>stretch-fit inline size</dfn>
		<dt><dfn>stretch-fit block size</dfn>
		<dd>
			The <a>size</a> a box would take
			if its <a>outer size</a> filled the <a>available space</a>
			in the given axis;
			in other words, the <a>stretch fit</a> into the <a>available space</a>,
			if that is <a>definite</a>.
			Undefined if the <a>available space</a> is <a>indefinite</a>.

			Note: For the <a>inline axis</a>, this is called the “available width” in <a href="https://www.w3.org/TR/CSS2/visudet.html#float-width">CSS2.1§10.3.5</a>
			and computed by the rules in <a href="https://www.w3.org/TR/CSS2/visudet.html#blockwidth">CSS2.1§10.3.3</a>.

			Note: Calculations involving this size need to specify a fallback behavior
			for when the <a>available space</a> is <a>indefinite</a>
			if that happens to be possible.

		<dt><dfn lt="max-content | max-content size">max-content size</dfn>
		<dd>
			A box’s “ideal” <a>size</a> in a given axis when given infinite available space.
			Usually this is the smallest <a>size</a> the box could take in that axis
			while still fitting around its contents,
			i.e. minimizing unfilled space while avoiding overflow.

			: <dfn>max-content inline size</dfn>
			:: The box's “ideal” <a>size</a> in the <a>inline axis</a>.
				Usually the narrowest <a>inline size</a> it could take while fitting around its contents
				if <em>none</em> of the soft wrap opportunities within the box were taken.
				(See [[#intrinsic]].)

				Note: This is called the “preferred width” in <a href="https://www.w3.org/TR/CSS2/visudet.html#float-width">CSS2.1§10.3.5</a>
				and the “maximum cell width” in <a href="https://www.w3.org/TR/CSS2/tables.html#auto-table-layout">CSS2.1§17.5.2.2</a>.

			: <dfn>max-content block size</dfn>
			:: The box's “ideal” <a>size</a> in the <a>block axis</a>.
				Usually the <a>block size</a> of the content after layout.

		<dt><dfn lt="min-content | min-content size">min-content size</dfn>
		<dd>
			Nominally, the smallest <a>size</a> a box could take
			that doesn't lead to overflow
			that could be avoided by choosing a larger <a>size</a>.
			Formally, the size of the box when sized under a [=min-content constraint=],
			see [[#intrinsic]].

			: <dfn>min-content inline size</dfn>
			:: The [=min-content size=] in the [=inline axis=].
				Typically, the <a>inline size</a> that would fit around its contents
				if <em>all</em> soft wrap opportunities within the box were taken.

				Note: This is called the “preferred minimum width” in <a href="https://www.w3.org/TR/CSS2/visudet.html#float-width">CSS2.1§10.3.5</a>
				and the “minimum content width” in <a href="https://www.w3.org/TR/CSS2/tables.html#auto-table-layout">CSS2.1§17.5.2.2</a>.

			: <dfn>min-content block size</dfn>
			:: The [=min-content size=] in the [=block axis=].
				For [=block containers=], tables, and [=inline boxes=],
				this is equivalent to the <a>max-content block size</a>.

		<dt><dfn>fit-content size</dfn>
		<dt><dfn>fit-content inline size</dfn>
		<dt><dfn>fit-content block size</dfn>
		<dd>
			If the <a>available space</a> in a given axis is <a>definite</a>,
			equal to <code>clamp([=min-content size=], [=stretch-fit size=], [=max-content size=])</code>
			(i.e. <code>max(<a>min-content size</a>, min(<a>max-content size</a>, <a>stretch-fit size</a>))</code>).
			When sizing under a [=min-content constraint=],
			equal to the [=min-content size=].
			Otherwise, equal to the <a>max-content size</a> in that axis.

			Note: This is called the “shrink-to-fit” width in <a href="https://www.w3.org/TR/CSS2/visudet.html#float-width">CSS2.1§10.3.5</a>
			and <a href="https://www.w3.org/TR/css3-multicol/#pseudo-algorithm">CSS Multi-column Layout § 3.4</a>.

		<dt><dfn>intrinsic size</dfn>
		<dd>
			A <a>max-content size</a> or <a>min-content size</a>,
			i.e. a size arising primarily from the size of the content.
			(Some uses of this term may refer also to sizes
			derived primarily from one of these two sizes.)

			[=Replaced elements=] frequently derive their [=intrinsic size=]
			from their [=natural dimensions=].
	</dl>

<h3 id='contributions'>
Intrinsic Size Contributions</h3>

	<dl export>
		<dt><dfn lt="max-content contribution|max-content inline-size contribution|max-content block-size contribution">max-content contribution</dfn>
		<dd>
			The size that a box contributes to its <a>containing block</a>'s <a>max-content size</a>.

		<dt><dfn lt="min-content contribution|min-content inline-size contribution|min-content block-size contribution">min-content contribution</dfn>
		<dd>
			The size that a box contributes to its <a>containing block</a>'s <a>min-content size</a>.

		<dt><dfn>intrinsic size contribution</dfn>
		<dd>
			A <a>max-content contribution</a>, <a>min-content contribution</a>,
			or similarly-calculated content-based size contribution.
	</dl>

	Intrinsic size contributions are based on the <a>outer size</a> of the box;
	for this purpose ''margin/auto'' margins are treated as zero.

<h3 id='constraints' dfn export lt="intrinsic size constraint">
Intrinsic Size Constraints</h3>

	<dl export>
		<dt><dfn>max-content constraint</dfn>
		<dd>
			A sizing constraint imposed by the box's <a>containing block</a>
			that causes it to produce its <a>max-content contribution</a>.

		<dt><dfn>min-content constraint</dfn>
		<dd>
			A sizing constraint imposed by the box's <a>containing block</a>
			that causes it to produce its <a>min-content contribution</a>.

		<dt><dfn>preferred aspect ratio</dfn>
		<dd>
			A width:height ratio inherent to a box,
			which biases various sizing algorithms
			to produce a size consistent with that aspect ratio
			insofar as possible while honoring other sizing inputs.
			Unless otherwise specified,
			a box’s [=preferred aspect ratio=] is its [=natural aspect ratio=] if it has one
			and is applied to its [=content box=].
			Most boxes do not have a [=preferred aspect ratio=].
	</dl>

<!--
████████  ████████   ███████  ████████  ████████  ████████ ████████  ██████
██     ██ ██     ██ ██     ██ ██     ██ ██     ██ ██       ██       ██    ██
██     ██ ██     ██ ██     ██ ██     ██ ██     ██ ██       ██       ██
████████  ████████  ██     ██ ████████  ██     ██ ██████   ██████    ██████
██        ██   ██   ██     ██ ██        ██     ██ ██       ██             ██
██        ██    ██  ██     ██ ██        ██     ██ ██       ██       ██    ██
██        ██     ██  ███████  ██        ████████  ████████ ██        ██████
-->

<h2 id="specifying-sizes" oldids='size-keywords'>
Specifying Box Sizes</h2>

<h3 id="sizing-properties">
Sizing Properties</h3>

	This section defines the <dfn export lt="sizing property">sizing properties</dfn>
	'width', 'height', 'min-width', 'min-height', 'max-width', and 'max-height'.
	Their potential values are defined in the next section,
	[[#sizing-values]].

	Note: Additional <a>flow-relative</a> aliases to these properties are defined in [[CSS-LOGICAL-1]].

	ISSUE: We would like to define shorthands for each pair of sizing properties
	(e.g. 'width' and 'height')
	but there is a naming conflict with the ''@page'' '@page/size' descriptor [[CSS-PAGE-3]],
	so this has been deferred to Level 4.
	Suggestions on how to resolve this problem are welcome,
	see <a href="https://github.com/w3c/csswg-drafts/issues/820">discussion</a>.

<h4 id="preferred-size-properties" dfn export lt="preferred size property">
Preferred Size Properties: the 'width' and 'height' properties</h4>

	<pre class=propdef>
	Name: width, height
	Value: auto | <<length-percentage [0,∞]>> | min-content | max-content | <nobr>fit-content(<<length-percentage [0,∞]>>)</nobr> | <<width/calc-size()>>
	Initial: auto
	Applies to: all elements except <a>non-replaced</a> <a>inlines</a>
	Inherited: no
	Logical property group: size
	Percentages: relative to width/height of <a>containing block</a>
	Computed Value: as specified, with <<length-percentage>> values computed
	Animation type: by computed value type, recursing into ''width/fit-content()''
	</pre>

	The 'width' and 'height' ([=physical=]) properties specify
	the <dfn export lt="preferred size">preferred</dfn>
	<dfn export lt="width | preferred width">width</dfn>
	and <dfn export lt="height | preferred height">height</dfn> of the box, respectively.

<h4 id="min-size-properties" dfn export lt="min size property">
Minimum Size Properties: the 'min-width' and 'min-height' properties</h4>

	<pre class=propdef>
	Name: min-width, min-height
	Value: auto | <<length-percentage [0,∞]>> | min-content | max-content | <nobr>fit-content(<<length-percentage [0,∞]>>)</nobr> | <<min-width/calc-size()>>
	Initial: auto
	Applies to: all elements that accept 'width' or 'height'
	Inherited: no
	Logical property group: min-size
	Percentages: relative to width/height of <a>containing block</a>
	Computed Value: as specified, with <<length-percentage>> values computed
	Animation Type: by computed value, recursing into ''min-width/fit-content()''
	</pre>

	The 'min-width' and 'min-height' properties specify
	the <dfn export lt="min width | minimum width | min size | minimum size">minimum width</dfn> (or “min width”)
	and <dfn export lt="min height | minimum height">minimum height</dfn> (or “min height”)
	of the box, respectively.

	Note: The initial value of ''min-width/auto'' is new;
	in [[CSS2]] the initial value was zero.

<h4 id="max-size-properties" dfn export lt="max size property">
Maximum Size Properties: the 'max-width' and 'max-height' properties</h4>

	<pre class=propdef>
	Name: max-width, max-height
	Value: none | <<length-percentage [0,∞]>> | min-content | max-content | <nobr>fit-content(<<length-percentage [0,∞]>>)</nobr> | <<max-width/calc-size()>>
	Initial: none
	Applies to: all elements that accept 'width' or 'height'
	Inherited: no
	Logical property group: max-size
	Percentages: relative to width/height of <a>containing block</a>
	Computed Value: as specified, with <<length-percentage>> values computed
	Animation Type: by computed value, recursing into ''max-width/fit-content()''
	</pre>

	The 'max-width' and 'max-height' properties specify
	the <dfn export lt="max width | maximum width | max size | maximum size">maximum width</dfn> (or “max width”)
	and <dfn export lt="max height | maximum height">maximum height</dfn> (or “max height”)
	of the box, respectively.


<h3 id="sizing-values" oldids='width-height-keywords'>
Sizing Values: the <<length-percentage [0,∞]>>, ''width/auto'' | ''max-width/none'', ''width/min-content'', ''width/max-content'', and ''width/fit-content()'' values</h3>

	<dl dfn-type=value dfn-for="width, min-width, max-width, height, min-height, max-height">
		<dt><dfn><<length-percentage [0,∞]>></dfn>
		<dd>
			Specifies the size of the box using <<length>> and/or <<percentage>>.
			The 'box-sizing' property indicates whether the <a>content box</a> or <a>border box</a> is measured.

			Percentages are resolved against the width/height, as appropriate,
			of the box's <a>containing block</a>.
			If, in a particular axis,
			the <a>containing block’s</a> size depends on the box’s size,
			see the relevant layout module
			for special rules on how to resolve percentages.

			Negative values are invalid.

		<dt><dfn for="width, height, min-width, min-height">auto</dfn>
		<dd>
			For 'width'/'height', specifies an <dfn export dfn for>automatic size</dfn>
			(<dfn export dfn for>automatic [=block size=]</dfn>/<dfn export dfn for>automatic [=inline size=]</dfn>).
			See the relevant layout module for how to calculate this.

			For 'min-width'/'min-height',
			specifies an <dfn export dfn for>automatic minimum size</dfn>.
			Unless otherwise defined by the relevant layout module,
			however,
			it resolves to a used value of ''0''.
			For backwards-compatibility,
			the <a>resolved value</a> of this keyword is zero
			for boxes of all [[!CSS2]] <a>display types</a>:
			block and inline boxes,
			inline blocks,
			and all the table layout boxes.
			It also resolves to zero
			when no box is generated.

		<dt><dfn for="max-width, max-height">none</dfn>
		<dd>
			No limit on the size of the box.

<!--
		<dt><dfn>stretch</dfn>
		<dd>
			If 'align-self' or 'justify-self' (as appropriate to the relevant axis)
			is defined to apply,
			size the box as if ''align-self/stretch'' were specified for that property.
			(If the box does not exactly fill its <a>alignment container</a>,
			the <a>box alignment properties</a> will dictate how the size differential is handled.)
			Otherwise,
			this value behaves as the initial value.

			NOTE: For the <a>inline size</a> of a <a>block-level box</a>,
			this is exactly the formula used to calculate ''width/auto'' widths
			for non-replaced blocks in normal flow, see <a href="https://www.w3.org/TR/CSS2/visudet.html#blockwidth">CSS2.1§10.3.3</a>.
			It allows re-using this formula for boxes that are otherwise shrink-wrapped,
			like tables.
-->

		<dt><dfn>min-content</dfn>
		<dd>
			Use the <a>min-content size</a> in the relevant axis;
			for a box’s [=block size=],
			unless otherwise specified,
			this is equivalent to its [=automatic size=].

		<dt><dfn>max-content</dfn>
		<dd>
			Use the <a>max-content size</a> in the relevant axis;
			for a box’s [=block size=],
			unless otherwise specified,
			this is equivalent to its [=automatic size=].
<!--
		<dt><dfn>fit-content</dfn>
		<dd>
			Use the <a>fit-content size</a> in the relevant axis,
			i.e.
			<code>min(''width/max-content'', max(''width/min-content'', ''width/stretch''))</code>.
-->
		<dt><dfn function lt="fit-content()">fit-content(<<length-percentage [0,∞]>>)</dfn>
		<dd>
			Use the fit-content formula
			with the <a>available space</a> replaced by the specified argument,
			i.e.
			<code>min(''width/max-content'', max(''width/min-content'', <<length-percentage>>))</code>,
			where the <<length-percentage>> argument is resolved
			exactly as for <<length-percentage>> values standing alone.

			Negative <<length-percentage>> values are invalid.

		<dt><dfn function lt="calc-size()">calc-size()</dfn>
		<dd>
			See <</calc-size()>>.

			Note: The ''max-width/none'' keyword is
			not usable within ''max-width/calc-size()''.

	</dl>

	In all cases,
	the used value is floored to preserve a non-negative <a>inner size</a>.

	Note: The ''width/min-content'', ''width/max-content'', and ''width/fit-content()'' values
	are new in Level 3.

	Note: The 'flex-basis' property hereby also gains these new keywords,
	as its values are defined by reference to <'width'>.

	Note: This section previously defined ''width/stretch'' and ''width/fit-content''
	as keywords representing the <a>stretch-fit size</a> and <a>fit-content size</a>,
	respectively.
	These keywords have been deferred to Level 4
	(along with an additional ''width/contain'' keyword that
	behaves similarly to ''width/stretch''
	but preserves the [=preferred aspect ratio=], if any)
	to better work out the implications in situations with
	<a>indefinite</a> <a>available space</a>.

<h4 id="behave-auto">
“Behaving as ''width/auto''”</h4>

<!-- THIS NEED SOME THINKING THROUGH, WE DID WEIRD THINGS WITH FLEXBOX/GRID
	Note: Percentages resolved against the intrinsic sizes
	(''width/max-content'', ''width/min-content'', ''width/fit-content'')
	will behave as ''width/auto''.
-->
	<!-- <a href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property">as defined by CSS 2</a>. [[!CSS2]] -->
	<!-- Restore the above when 2.1 is updated and published with the new "behaves as" text we resolved on. -->

	To have a common term for both when
	'width'/'height' computes to ''width/auto''
	and when it is defined to behave as if ''width/auto'' were specified
	(as in the case of <a href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property">block percentage heights</a>
	resolving against an <a>indefinite</a> size,
	see <a href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property">CSS2&sect;10.5</a>),
	the property is said to <dfn export lt="behave as auto|behaves as auto|behaving as auto">behave as auto</dfn>
	in both of these cases.

	Note: Legacy spec prose defining layout behavior, particularly in [[CSS2]],
	might explicitly refer to 'width'/'height' having a computed value of ''width/auto'' as a condition;
	some of these cases should be interpreted as meaning <a>behaves as auto</a>,
	and reported to the CSSWG for updating.

	ISSUE: Replace this section with references to the new term <a>automatic size</a>.

<h4 id='the-contain-floats-value'>
Containing or Excluding Floats</h4>

	<em>This section is non-normative.</em>

	Although <a>block box</a> boundaries are typically pervious to floats,
	sometimes an author needs them to contain their own (descendant) floats
	or to exclude floats from outside.
	For Block layout,
	specifying ''display: flow-root''
	will make the box a <a>formatting context</a> root,
	which has this behavior.

	Note: Boxes participating in Flex, Grid, or Table layout will automatically have this behavior.

<!--
████████   ███████  ██     ██          ██████  ████ ████████ ████ ██    ██  ██████
██     ██ ██     ██  ██   ██          ██    ██  ██       ██   ██  ███   ██ ██    ██
██     ██ ██     ██   ██ ██           ██        ██      ██    ██  ████  ██ ██
████████  ██     ██    ███    ███████  ██████   ██     ██     ██  ██ ██ ██ ██   ████
██     ██ ██     ██   ██ ██                 ██  ██    ██      ██  ██  ████ ██    ██
██     ██ ██     ██  ██   ██          ██    ██  ██   ██       ██  ██   ███ ██    ██
████████   ███████  ██     ██          ██████  ████ ████████ ████ ██    ██  ██████
-->

<h3 id="box-sizing" caniuse="css3-boxsizing">
Box Edges for Sizing: the 'box-sizing' property</h3>


	<pre class="propdef">
	Name: box-sizing
	Value: content-box | border-box
	Initial: content-box
	Applies to: all elements that accept 'width' or 'height'
	Inherited: no
	Percentages: N/A
	Computed value: specified keyword
	Animation type: discrete
	</pre>

	The 'box-sizing' property defines whether
	fixed sizes (such as <<length>>s and <<percentage>>s)
	are assigned to the <a>content box</a> or to the <a>border box</a>.
	It affects the interpretation of all <a>sizing properties</a>,
	including 'flex-basis'.

	Values have the following meanings:

	<dl dfn-type=value dfn-for=box-sizing>
		<dt><dfn>content-box</dfn>
		<dd>
			Sizes specified on <a>sizing properties</a>
			as <<length-percentage>>
			represent the box’s <a>inner sizes</a>,
			excluding the margins/border/padding:
			they are applied to the <a>content box</a>.
			The padding and border of the box
			are laid out and drawn <em>outside</em> the specified 'width' and 'height'.

			Note: This is the behavior of width and height as specified by CSS2.1,
			and is thus the default.

		<dt><dfn>border-box</dfn>
		<dd>
			Sizes specified on <a>sizing properties</a>
			as <<length-percentage>>
			represent the box’s visually-apparent sizes,
			including the borders/padding (but not margin):
			they are applied to the <a>border box</a>.
			The padding and border of the box
			are laid out and drawn <em>inside</em> the specified 'width' and 'height',
			with the <a>content box</a> sized to fill the remaining space,
			floored at zero.

			The content width and height are calculated
			by subtracting the border and padding widths of the respective sides
			from the specified <<length-percentage>>.
			As the content width and height
			[[#sizing-values|cannot be negative]],
			this computation is floored at zero.

			Used values, as exposed for instance through {{getComputedStyle()}},
			also refer to the border box.
	</dl>

	Values affected by 'box-sizing' include
	both raw <<length-percentage>> values
	and those used in functional notations such as ''width/fit-content()''.
	In contrast,
	non-quantitative values such as ''width/auto'' and ''width/min-content''
	are not influenced by the 'box-sizing' property
	(unless otherwise specified).

	<div class=example>
		For example, the following properties set
		the content-box size of the box to ''100px'',
		with the border-box size calculating to ''120px'':

		<pre class=lang-css>
		.box {
			box-sizing:   content-box; /* default */
			width:        100px;
			padding-left: 10px;
			border-left:  10px solid;
		}
		</pre>

		On the other hand, by changing to ''border-box'',
		the border-box is set to ''100px'',
		with the content-box size calculating to ''80px'':

		<pre class=lang-css>
		.box {
			box-sizing:   border-box;
			width:        100px;
			padding-left: 10px;
			border-left:  10px solid;
		}
		</pre>

		The <a>inner size</a> can't be less than zero,
		so if the 'padding' + 'border' is greater than the specified border-box size,
		the box will end up larger than specified.
		In this case, the content-box size will floor at ''0px''
		so the border-box size ends up at ''120px'',
		even though ''width: 100px'' is specified for the border box:

		<pre class=lang-css>
		.box {
			box-sizing:   border-box;
			width:        100px;
			padding-left: 60px;
			border-left:  60px solid;
			/* padding + border = 120px */
		}
		</pre>
	</div>

	<div class="example">
		This example uses box-sizing to evenly horizontally split
		two divs with fixed size borders inside a div container,
		which would otherwise require additional markup.

		sample CSS:
		<pre><code class="lang-css">
		div.container {
			width:38em;
			border:1em solid black;
		}

		div.split {
			box-sizing:border-box;
			width:50%;
			border:1em silver ridge;
			float:left;
		}
		</code></pre>

		sample HTML fragment:
		<pre><code class="lang-markup">
		&lt;div class="container"&gt;
		&lt;div class="split"&gt;This div occupies the left half.&lt;/div&gt;
		&lt;div class="split"&gt;This div occupies the right half.&lt;/div&gt;
		&lt;/div&gt;
		</code></pre>

		demonstration of sample CSS and HTML:
		<div style="max-width:38em; border:1em solid black"><div style="box-sizing:border-box; width:50%; border:1em silver ridge; float:left">This div should occupy the left half.</div><div style="box-sizing:border-box; width:50%; border:1em silver ridge; float:left">This div should occupy the right half.</div>The two divs above should appear side by side, each (including borders) 50% of the content width of their container. If instead they are stacked one on top of the other then your browser does not support 'box-sizing'.</div>
	</div>

	Note: Certain HTML elements,
	such as <{button}>,
	default to ''border-box'' behavior.
	See HTML for details on which elements have this behavior.

	In legacy CSS specifications,
	the terms <a>width</a>, <a>height</a>,
	<a lt="min width">minimum (min) width</a>,
	<a lt="min height">minimum (min) height</a>,
	<a lt="max width">maximum (max) width</a>, and
	<a lt="max height">maximum (max) height</a>
	generally refer to the <a lt="inner size">inner</a> size
	(<a lt="content box">content-box</a> size)
	of a <a>box</a>
	unless otherwise indicated.

	Refer to [[CSS-UI-3#box-sizing]] for an explicit disambiguation of these terms
	for the <a href="https://www.w3.org/TR/CSS21/visudet.html">Visual formatting model details</a> section of [[CSS2]].

	<div class=advisement>To avoid ambiguities,
	specification authors should avoid ambiguous uses of terms such as width or height without further qualification,
	and should explicitly refer and link to
	the <a lt="inner size">inner</a> size,
	the <a lt="outer size">outer</a> size,
	the size of the <a href="https://www.w3.org/TR/css2/box.html#box-dimensions">border-box</a>,
	the <a>computed value</a> of the <a>sizing properties</a>,
	etc,
	as appropriate for each case.
	</div>

<!--
 ██████   ███████  ██       ██     ██ ██     ██ ██    ██
██    ██ ██     ██ ██       ██     ██ ███   ███ ███   ██
██       ██     ██ ██       ██     ██ ████ ████ ████  ██
██       ██     ██ ██       ██     ██ ██ ███ ██ ██ ██ ██
██       ██     ██ ██       ██     ██ ██     ██ ██  ████
██    ██ ██     ██ ██       ██     ██ ██     ██ ██   ███
 ██████   ███████  ████████  ███████  ██     ██ ██    ██
-->

<h3 id='column-sizing'>
New Column Sizing Values: the ''column-width/min-content'', ''column-width/max-content'', and ''column-width/fit-content()'' values</h3>

	<pre class="propdef partial">
	Name: column-width
	New values: min-content | max-content | fit-content(<<length-percentage>>)
	Computed value: as specified, with <<length-percentage>> values computed
	Animation type: by computed value type
	</pre>

	<p>When  used as values for 'column-width',
		the new keywords specify the optimal column width:

	<dl dfn-type=value dfn-for="column-width">
<!--
		<dt><dfn>stretch</dfn>
		<dd>Specifies the optimal column width as the <a>stretch-fit inline size</a>
			of the multi-column container.
-->

		<dt><dfn>min-content</dfn>
		<dd>Specifies the optimal column width as the <a>min-content inline size</a>
			of the multi-column container's contents.

		<dt><dfn>max-content</dfn>
		<dd>Specifies the optimal column width as the <a>max-content inline size</a>
			of the multi-column container's contents.
<!--
		<dt><dfn>fit-content</dfn>
		<dd>Specifies the optimal column width as
			<code>min(<a>max-content inline size</a>, max(<a>min-content inline size</a>, <a>stretch-fit inline size</a>))</code>.
-->
		<dt><dfn>fit-content(<<length-percentage>>)</dfn>
		<dd>
			Specifies the optimal column width as
			<code>min(<a>max-content size</a>, max(<a>min-content size</a>, <<length-percentage>>))</code>
	</dl>

	Note: The column width never varies by column.
	When the column width is informed by the multi-column container's contents
	(as in the keywords above),
	all of its contents are taken under consideration
	and the calculated width is shared by all the columns.

<!--
████████ ██     ██ ████████ ████████  ████ ██    ██  ██████  ████  ██████
██        ██   ██     ██    ██     ██  ██  ███   ██ ██    ██  ██  ██    ██
██         ██ ██      ██    ██     ██  ██  ████  ██ ██        ██  ██
██████      ███       ██    ████████   ██  ██ ██ ██  ██████   ██  ██
██         ██ ██      ██    ██   ██    ██  ██  ████       ██  ██  ██
██        ██   ██     ██    ██    ██   ██  ██   ███ ██    ██  ██  ██    ██
████████ ██     ██    ██    ██     ██ ████ ██    ██  ██████  ████  ██████
-->

<h2 id='extrinsic'>
Extrinsic Size Determination</h2>

	<p>
		<dfn export>Extrinsic sizing</dfn> determines sizes based on the context of an element,
		without regard for its contents.


<h3 id="percentage-sizing">
	Percentage Sizing</h3>

	Percentages specify sizing of a box with respect to the box’s <a>containing block</a>.

	<div class="example">
		For example, in the following markup:

		<xmp class='lang-html'>
			<article style="height: 60em">
				<figure style="height: 50%;">
					<img style="height: 50%;">
				</figure>
			</article>
		</xmp>

		* the <code>&lt;figure></code> would be ''30em'' tall
			= 50% of the [=definite=] ''60em'' height of the <code>&lt;article></code>
		* the <code>&lt;img></code> would be ''15em'' tall
			= 50% of the <code>&lt;figure></code>’s height
			(which is itself [=definite=] because it's a percentage resolved against a [=definite=] length)
	</div>

	See [[#cyclic-percentage-contribution]]
	for details on how to resolve percentages
	when the size of the [=containing block=] depends
	on the size of its content.

<!--
████ ██    ██ ████████ ████████  ████ ██    ██  ██████  ████  ██████
 ██  ███   ██    ██    ██     ██  ██  ███   ██ ██    ██  ██  ██    ██
 ██  ████  ██    ██    ██     ██  ██  ████  ██ ██        ██  ██
 ██  ██ ██ ██    ██    ████████   ██  ██ ██ ██  ██████   ██  ██
 ██  ██  ████    ██    ██   ██    ██  ██  ████       ██  ██  ██
 ██  ██   ███    ██    ██    ██   ██  ██   ███ ██    ██  ██  ██    ██
████ ██    ██    ██    ██     ██ ████ ██    ██  ██████  ████  ██████
-->

<h2 id='intrinsic'>
Intrinsic Size Determination</h2>

	<p>
		<dfn export>Intrinsic sizing</dfn> determines sizes based on the contents of an element,
		without regard for its context.

<h3 id='intrinsic-sizes'>
Intrinsic Sizes</h3>

	The <a>min-content size</a> of a box in each axis
	is the size it would have if it was
	a float given an ''width/auto'' [=preferred size=] in that axis
	(and no <a lt="min size">minimum</a> or <a>maximum size</a> in that axis)
	and if its containing block was <em>zero</em>-sized in that axis.
	(In other words, the minimum size it has when sized as “shrink-to-fit”.)

The <a>max-content size</a> of a box in each axis
is the size it would have if it was
a float given an ''width/auto'' [=preferred size=] in that axis
(and no <a lt="min size">minimum</a> or <a>maximum size</a> in that axis),
and if its containing block was <em>infinitely</em>-sized in that axis.
(In other words, the maximum size it has when sized as “shrink-to-fit”.)

The [=min-content size=] and [=max-content size=] are collectively referred to
as the [=intrinsic sizes=].

Note: When the box has a [=preferred aspect ratio=],
size constraints in the opposite dimension will transfer through
and can affect the ''width/auto'' size in the considered one.
See <a href="https://www.w3.org/TR/CSS2/visudet.html">CSS2&sect;10</a>.

This specification does not define how to determine the sizes of floats.
Please refer to [[CSS2]].
However, the [=intrinsic sizes=] of [=replaced elements=] without [=natural sizes=]
are defined below:

<dl>
	<dt>If it has a [=preferred aspect ratio=]:
	<dd>
		For the [=min-content size=], use zero.

		For the [=max-content size=]:

		* If the <a>available space</a> is <a>definite</a>
			in the <a>inline axis</a>,
			use the <a>stretch fit</a> into that size for the inline size
			and calculate the block size using the aspect ratio.
			<!-- Technically undefined in CSS2, but this was recommended. -->

		* Otherwise
			if the box has a <<length>> as its [=computed value=]
			for 'min-width' or 'min-height',
			use that size and calculate the other dimension using the aspect ratio;
			if both dimensions have a <<length>> minimum,
			choose the one that results in the larger overall size.

			Note: This case was previous calculated from a 300x150 default size,
			rather than the box's min size.
			This is believed to be a better behavior,
			and likely to be Web-compatible,
			but please send feedback to the CSSWG if there are any problems.
			<!-- Brand new behavior not defined in CSS2 -->

		* Otherwise
			use an [=inline size=] matching
			the corresponding dimension of the [=initial containing block=]
			and calculate the other dimension using the aspect ratio.
			<!-- More brand-new behavior, to prevent max-content size from going infinite. -->

	<dt>If it has no [=preferred aspect ratio=]:
	<dd>
		For both the [=min-content size=] and [=max-content size=]:

		* If the box has a <<length>> as its [=computed value|computed=]
			[=minimum size=] ('min-width'/'min-height') in that dimension,
			use that size.

			Note: This author-controllable behavior is made possible
			by the new ''min-width/auto'' value for the [=min size properties=].
			This is believed to be a better behavior,
			but it is not yet clear if it is Web-compatible,
			so please send feedback to the CSSWG if there are any problems.

		* Otherwise,
			use ''300px'' for the width
			and/or ''150px'' for the height
			as needed.
			<!-- Required by CSS2 (due to Web-compat). -->
</dl>

	Since a block-level or inline-level replaced element
	whose 'height' or 'width' <a>behaves as auto</a>
	is effectively defined to use its <a>max-content size</a>
	(<a href="https://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width">CSS2&sect;10.3.2</a>),
	this specification applies the rules above
	to the undefined case of a replaced element
	whose 'height' and 'width' both <a>behave as auto</a>.

	Note: This specification does not define how to determine
	the size of a float.
	Please refer to [[CSS2]],
	the relevant CSS specification for that display type,
	and/or existing implementations
	for further details.
	A future specification will define this in detail,
	replacing the CSS2 “definition”,
	such as it is.

	<hr>

	Although the ''width/auto'' size of text input controls
	such as HTML’s <code>&lt;input type=text></code> and <code>&lt;textarea></code> elements
	is typically a fixed size,
	the contents of such elements can be used to determine a content-based [=intrinsic size=],
	as for non-replaced block containers.
	The ''width/min-content'' and ''width/max-content'' keywords of the <a>sizing properties</a>
	thus represent content-based sizes
	for form controls which render their value
	as text contained within their box,
	allowing such controls to size to fit their visible contents
	similarly to regular non-replaced elements.

	The content in this case is defined to be the input control's values
	(the <l spec=html>[=raw value=]</l> in the case of <{textarea}>,
	or the <a href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-value">value</a> in the case of <{input}>),
	possibly transformed to a more human-readable and/or localized display format,
	which is then treated as child <a>text sequences</a> of the input control,
	allowing <a>soft wrap opportunities</a>
	only where the input control would actually allow wrapping
	(whether keyed off of CSS properties or other, UA-internal constraints).
	If the input control has designated placeholder text
	to be overlaid in its value display area,
	then that text is also measured for the purpose of calculating the content-based size--
	whether or not the placeholder text is visible at the moment.
	(Thus the content-based [=intrinsic size=] of the input control
	is the larger of the size to fit the placeholder text and the size to fit the value.)

	The UA may enforce a minimum
	(such as the size required to contain a single zero-width character,
	or the smallest usable size of a touch target)
	on the form control’s
	<a lt="min-content size">min-content</a> and <a>max-content sizes</a>
	to ensure sufficient space for the caret
	and otherwise maintain usability of the form control.

	Note:
	This might be extended to <{iframe}> or other content-containing replaced elements
	(see <a href="https://github.com/w3c/csswg-drafts/issues/1771">discussion</a>),
	but text inputs are a major use-case;
	and being document-internal,
	have the least additional complications.

<h3 id="intrinsic-contribution">
Intrinsic Contributions</h3>

	A box’s <a>min-content contribution</a>/<a>max-content contribution</a> in each axis
	is the size of the content box
	of a hypothetical ''width/auto''-sized float
	that contains only that box,
	if that hypothetical float's containing block is zero-sized/infinitely-sized.

	Note: This specification does not define precisely how to determine these sizes.
	Please refer to [[CSS2]],
	the relevant CSS specification for that display type,
	the <a href="#percentage-sizing">rules for handling percentages</a> (below),
	and/or existing implementations
	for further details.

<h4 id="cyclic-percentage-contribution">
Intrinsic Contributions of Percentage-Sized Boxes</h4>

	Sometimes the size of a percentage-sized box’s <a>containing block</a>
	depends on the [=intrinsic size contribution=] of the box itself,
	creating a cyclic dependency.
	When calculating the <a>intrinsic size contribution</a> of such a box
	(including any calculations for a content-based <a>automatic minimum size</a>),
	a percentage value that resolves against a size
	in the same axis as the [=intrinsic size contribution=]
	(a <dfn export local-lt="cyclic percentage">cyclic percentage size</dfn>)
	is resolved specially:

	<ol type=a>
		<li id=non-replaced-percentage-contribution>
		If the box is [=non-replaced=],
		then the entire value of any
		[=max size property=] or [=preferred size property=]
		('width'/'max-width'/'height'/'max-height')
		specified as an expression [=containing a percentage=]
		(such as ''10%'' or ''calc(10px + 0%)'')
		that is <a lt="cyclic percentage">cyclic</a>
		is treated
		<em>for the purpose of calculating the box’s [=intrinsic size contributions=] only</em>
		as that property’s [=initial value=].
		For example, given a box with ''width: calc(20px + 50%)'',
		its max-content contribution is calculated as if its 'width' were ''width/auto''.
		(The percentage is honored as usual, however,
		during the actual sizing of the box itself; see below.)

		<li id=replaced-percentage-max-contribution>
		Likewise, if the box is [=replaced element|replaced=],
		then the entire value of any
		[=max size property=] or [=preferred size property=]
		specified as an expression containing a percentage
		that is <a lt="cyclic percentage">cyclic</a>
		is treated
		<em>for the purpose of calculating the box’s <a>max-content contributions</a> only</em>
		as that property’s [=initial value=].

		<li id=replaced-percentage-min-contribution>
		If the box is [=replaced element|replaced=],
		a <a>cyclic percentage</a> in the value of any
		[=max size property=] or [=preferred size property=]
		('width'/'max-width'/'height'/'max-height'),
		is resolved against zero
		when calculating the <a>min-content contribution</a> in the corresponding axis.
		(See [[#min-content-zero]] for a list of which elements in HTML this applies to.)
		If the box also has a [=preferred aspect ratio=],
		then this [=min-content contribution=] is floored
		by any <<length-percentage>> [=minimum size=] from the opposite axis--
		resolving any such percentage against zero--
		transferred through the [=preferred aspect ratio=].
		<!-- https://github.com/w3c/csswg-drafts/issues/6341 -->

		ISSUE: Should we resolve transferred percentages against their containing block instead of zero before transferring them? See <a href="https://github.com/w3c/csswg-drafts/issues/6341">discussion</a>.

		The UA may additionally floor the [=min-content contribution=]
		based on UI considerations,
		such as ensuring certain UI elements remain visible
		(for example, the dropdown arrow on a <{select}>).

		Note: The [=min-content contribution=] is, as always,
		also floored by the [=minimum size=] in its own axis.

		This rule also applies when calculating
		a content-based <a>automatic minimum size</a>
		or its corresponding size contribution,
		yielding a <a>definite</a> “specified size suggestion”.

		<div class=example>
			For example,
			an <{input}> assigned ''width: calc(50% + 50px)''
			has a <a>min-content contribution</a> of ''50px'',
			plus any horizontal margin/border/padding.
		</div>

		<li id=min-percentage-contribution>
		For the [=min size properties=],
		as well as for [=margins=] and [=paddings=]
		(and [=gutters=]),
		a <a>cyclic percentage</a> is resolved against zero
		for determining [=intrinsic size contributions=].
	</ol>

	<table class="data">
		<caption>Summary of the Cyclic-Percentage Intrinsic Size Contribution Rules (Above)</caption>
		<colgroup span=1></colgroup>
		<colgroup span=2></colgroup>
		<colgroup span=2></colgroup>
		<thead>
			<tr>
				<th scope=row>Element Type
				<th colspan=2 scope=colgroup>[=Replaced=]
				<th colspan=2 scope=colgroup>[=Non-replaced=]
			<tr>
				<th scope=row>Contribution Type
				<th scope=col>[=min-content contribution|min-content=]
				<th scope=col>[=max-content contribution|max-content=]
				<th scope=col>[=min-content contribution|min-content=]
				<th scope=col>[=max-content contribution|max-content=]
		<tbody>
			<tr>
				<th scope=row>[=min size property|min size=] & [=margin properties|margin=]/[=padding properties|padding=]
				<td><a href="#min-percentage-contribution">zeroᵈ</a>
				<td><a href="#min-percentage-contribution">zeroᵈ</a>
				<td><a href="#min-percentage-contribution">zeroᵈ</a>
				<td><a href="#min-percentage-contribution">zeroᵈ</a>
			<tr>
				<th scope=row>[=max size property|max=] & [=preferred size property|preferred size=]
				<td><a href="#replaced-percentage-min-contribution">zeroᶜ</a>
				<td><a href="#replaced-percentage-max-contribution">initialᵇ</a>
				<td><a href="#non-replaced-percentage-contribution">initialᵃ</a>
				<td><a href="#non-replaced-percentage-contribution">initialᵃ</a>
	</table>
	<style>
		table.data th[scope=row] { text-align: right; text-align: end; }
	</style>


	Then, unless otherwise specified,
	when calculating the used sizes and positions of the containing block’s <em>contents</em>:

	* If the cyclic dependency was introduced due to
		a [=block-axis=] size other than a [=minimum size=] on the containing block
		(i.e. a 'block-size' or 'max-block-size' in most layout modes,
		or a 'flex-basis' in [=flex layout=])
		that causes it to depend on the size of its contents,
		the box’s percentage is not resolved and instead <a>behaves as auto</a>.

		Note: <a>Grid items</a> and <a>flex items</a>
		do allow percentages to resolve in this case.

	* Otherwise, the percentage is resolved against the containing block’s size.
		(The containing block’s size is not re-resolved based on the resulting size of the box;
		the contents might thus overflow or underflow the containing block).

	Note: These rules specify the previously-undefined behavior of this cyclic case
	in <a href="https://www.w3.org/TR/CSS2/visudet.html#the-width-property">CSS2&sect;10.2</a>,
	<a href="https://www.w3.org/TR/CSS2/box.html#margin-properties">CSS2&sect;8.3</a>,
	and
	<a href="https://www.w3.org/TR/CSS2/box.padding-properties">CSS2&sect;8.4</a>.
	Note also, the behavior in <a href="https://www.w3.org/TR/CSS2/visudet.html#the-height-property">CSS2&sect;10.5</a>
	is superseded in their respective specifications for layout modes
	(such as <a href="http://www.w3.org/TR/css-flexbox/">flex layout</a>)
	not described in CSS2.

	<div class="example">
		For example, in the following markup:

		<xmp class='lang-html'>
			<article style="width: min-content">
				<aside style="width: 50%;">
				LOOOOOOOOOOOOOOOOOOOONG
				</aside>
			</article>
		</xmp>

		When calculating the width of the outer <code>&lt;article></code>,
		the inner <code>&lt;aside></code> behaves as ''width: auto'',
		so the <code>&lt;article></code> sets itself to the width of the long word.
		Since the <code>&lt;article></code>’s width didn't depend on "real" layout,
		though, it's treated as <a>definite</a>
		for resolving the <code>&lt;aside></code>,
		whose width resolves to half that of the <code>&lt;article></code>.
	</div>

	<div class="example">
		In this example,

		<xmp class=lang-html>
			<article style="height:auto">
				<aside style="height: 50%;">
					<div class=block style="height: 150px;"></div>
				</aside>
				<section style="height: 30px;"></section>
			</article>
		</xmp>

		because the percentage <a>block size</a> ('height', in this case) on block-level elements
		is defined to not resolve inside content-sized containing blocks,
		the percentage height on the <code>&lt;aside></code> is ignored,
		that is, it behaves exactly as if ''height/auto'' were specified.
	</div>

	<div class=example>

		Issue: Letting percentages still resolve against a definite 'height'
		when the min-height is intrinsic is an open issue.
		(CSS2 has a general statement about "height depending on contents",
		which this technically is,
		even though CSS2 didn't have content-dependent keywords for 'min-height'.
		Since this is new, we think we could have this different behavior.)

		The following examples illustrate how block-axis percentages resolve against a containing block whose size depends on its contents.

		<xmp class=lang-html>
			<article style="height:100px; min-height: min-content;">
				<aside style="height: 50%;">
					<div style="height: 150px;"></div>
				</aside>
				<section style="height: 30px;"></section>
			</article>
		</xmp>

		The initial height of the <code>&lt;article></code> is 100px, as specified,
		which would make the <code>&lt;aside></code> 50px tall
		when it resolved its percentage.
		However, we must calculate the min-height,
		by substituting it in for 'height'.
		This causes the percentage on the <code>&lt;aside></code> to <a>behave as auto</a>,
		so the <code>&lt;aside></code> ends up 150px tall.
		The total height of the contents is thus 180px.
		This is larger than the specified 100px height,
		so the <code>&lt;article></code> gets adjusted to 180px tall.

		Then, since the percentage could <em>originally</em> resolve against the (100px) height,
		it now resolves against the 180px height,
		so the <code>&lt;aside></code> ends up being 90px tall.

		<xmp class=lang-html>
			<article style="height:auto; min-height: min-content;">
				<aside style="height: 50%;">
					<div class=block style="height: 150px;"></div>
				</aside>
				<section style="height: 30px;"></section>
			</article>
		</xmp>

		In this case, the percentage on the <code>&lt;aside></code> won't normally resolve,
		because the containing block's height is ''height/auto''
		(and thus depends on the size of its contents).
		Instead it <a>behaves as auto</a>,
		resulting in a height of 150px for the <code>&lt;aside></code>,
		and an initial height of 180px for the <code>&lt;article></code>
		The 'min-height' doesn't change this;
		''height: min-content;'' acts similarly to ''height: auto;''
		and results in the same sizes.

		<xmp class=lang-html>
			<article style="height:100px; min-height: min-content;">
				<aside style="height: 200%;">
					<div style="height: 150px;"></div>
				</aside>
				<section style="height: 30px;"></section>
			</article>
		</xmp>

		This is a variation on the first code block,
		and follows a similar path;
		the <code>&lt;aside></code> initially wants to compute to 200px tall
		(200% of the 100px containing block height).
		When we calculate the effects of 'min-height',
		the percentage <a>behaves as auto</a>,
		causing it to become 150px tall,
		and the total ''height/min-content'' height of the containing block
		to be 180px tall.
		Since this is larger than 100px,
		the <code>&lt;article></code> gets clamped to 180px,
		the percentage resolves against this new height,
		and the <code>&lt;aside></code> ends up being 360px tall,
		overflowing the <code>&lt;article></code>
	</div>

<h4 id="min-content-zero">
Compressible Replaced Elements</h4>

	In addition to the [=replaced elements=] listed
	in <a href="https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements">HTML&sect;14.4</a> [[!HTML]],
	the following HTML elements are also considered to be [=replaced elements=]
	for the purpose of the <a href="#replaced-percentage-min-contribution">percentage-sized replaced element rule</a> above,
	and can have their <a>min-content contribution</a> compressed
	when their 'width'/'height' or 'max-width'/'max-height'
	is expressed with a cyclic percentage size:

	* <{input}> with any <{input/type}> that is not "button-like";
		this can vary depending on the UA.

		A type is "button-like" in a particular UA if it displays similar to a <{button}> element,
		where it can contains actual content that determines the layout of the element.
		In most UAs, the "button", "reset", "submit", and "color" types are button-like;
		the "file" type is also partially button-like in some UAs,
		when it's displayed as a combination of a text input (shrinkable)
		and a button (button-like, and thus not shrinkable).

	* <{select}>, <{textarea}>, <{progress}>, <{meter}>, <{marquee}>.

	Issue(6348): Tracking web-compat & implementation progress of applying this to max-width/height in <a href="https://github.com/w3c/csswg-drafts/issues/6348">Issue 6348</a>.

<h2 class=no-num id="changes">
Changes</h2>

<h3 class=no-num id="changes-recent">
Recent Changes</h3>

	<p>
		Changes since the <a href="https://www.w3.org/TR/2020/WD-css-sizing-3-20201218/">18 December 2020 Working Draft</a> include:

	<ul>
		<li>Fixed the order of 'contain-intrinsic-size' values
			when ''contain-intrinsic-size/auto'' is combined with other values
			so that parsing is unambiguous.
			(<a href="https://github.com/w3c/csswg-drafts/issues/6391">Issue 6391</a>)
		<li>Clarified which elements are allowed to not have a last remembered size for ''contain-intrinsic-size: auto''.
			(<a href="https://github.com/w3c/csswg-drafts/issues/6220">Issue 6220</a>)
		<li>Limited ''contain-intrinsic-size: auto'' to when ''content-visibility'' is ''content-visibility/auto''.
			(<a href="https://github.com/w3c/csswg-drafts/issues/6308">Issue 6308</a>)
	</ul>

	<p>
		Changes since the <a href="https://www.w3.org/TR/2020/WD-css-sizing-3-20201218/">18 December 2020 Working Draft</a> include:

	<ul>
		<li>
			Fixed various errors in definition of max-content sizes of replaced elements
			in [[#intrinsic-sizes]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/6072">Issue 6072</a>)
		<li>
			Added missing statement handling [=min-content constraint=]
			to definition of [=fit-content size=].
		<li>
			Renamed replaced element “intrinsic” dimensions to “natural” dimensions
			in order to avoid confusion with [=intrinsic sizes=]
			(see <a href="https://github.com/w3c/csswg-drafts/issues/4961">Issue 4961</a>).
		<li>
			Various other minor editorial fixes and improvements.
	</ul>

	<p>
		Major changes since the <a href="https://www.w3.org/TR/2019/WD-css-sizing-3-20190522/">22 May 2019 Working Draft</a> include:

	<ul>
		<li>
			Defined that ''width/min-content'' and ''width/max-content''
			do not necessarily behave the same as the property’s initial value
			if otherwise specified (by the relevant layout module).
			(<a href="https://github.com/w3c/csswg-drafts/issues/3973">Issue 3973</a>)

		<li>
			Switched intrinsic contribution of ''width/fit-content()''
			to treat its argument as that argument would be treated alone
			for intrinsic contribution calculations
			and resolve the fit-content formula accordingly,
			rather than having special behavior for ''width/fit-content()'' resolution
			when calculating intrinsic contributions.
			(<a href="https://github.com/w3c/csswg-drafts/issues/3731">Issue 3731</a>)

		<li>
			Changed the [=max-content size=] of replaced boxes
			without an intrinsic size
			to use their [=minimum size=] in place of ICB or 300px&times;150px
			only when it is a <<length>>,
			see [[#intrinsic-sizes]].
			(<a href="https://github.com/w3c/csswg-drafts/issues/4217">Issue 4217</a>)

		<li>
			Switched default sizing of an object with a natural aspect ratio
			to use the ICB size instead of 300px&times;150px.
			(<a href="https://github.com/w3c/csswg-drafts/issues/4218">Issue 4218</a>)

		<li>
			Defined [=preferred aspect ratio=] and used it in place of “intrinsic aspect ratio” where appropriate.

		<li>
			Miscellaneous minor / editorial fixes.
	</ul>

	<p>
		Major changes since the <a href="https://www.w3.org/TR/2018/WD-css-sizing-3-20180304/">4 March 2018 Working Draft</a> include:

	<ul>
		<li>Imported the 'box-sizing' definition from <a href="https://www.w3.org/TR/css-ui-3/">CSS UI Level 3</a>.
		<li>More rigorously specified handling of <a>cyclic percentages</a>.
			(<a href="https://github.com/w3c/csswg-drafts/issues/1132">#1132</a>,
			 <a href="https://github.com/w3c/csswg-drafts/issues/2384">#2384</a>,
			 <a href="https://github.com/w3c/csswg-drafts/issues/2297">#2297</a>,
			 <a href="https://github.com/w3c/csswg-drafts/issues/2674">#2674</a>)
		<li>Changed the ''*-content'' values applied to the bock axis
			to not compute to the property’s initial value,
			but to rather “behave as” the property’s initial value.
			(<a href="https://github.com/w3c/csswg-drafts/issues/2708">#2708</a>)
		<li>Fixed miscellaneous trivial errors.
	</ul>

	<p>
		Major changes since the <a href="https://www.w3.org/TR/2017/WD-css-sizing-3-20170207/">7 February 2017 Working Draft</a> include:

	<ul>
		<li>More accurate definition of min-content and max-content sizes for replaced elements.
		<li>Compute new keywords to the initial value, not to a potentially non-existent ''width/auto'', when applied to the block axis.
		<li>Specify that percent sizes on replaced elements zero out their min-content contribution.
		<li>Fix confusing/wrong definition of percentage sizes resolved against a dependent containing block.
			(This may require further work.)
		<li>Deferred the ''width/stretch'' and ''width/fit-content'' keywords to Level 4
			to allow for further consideration of their behavior in <a>indefinite</a> containing blocks.
		<li>Pulled in full definitions for all of the sizing properties (rather than diffing them):
			'width', 'height', 'min-width', 'min-height', max-width', 'max-height', and 'box-sizing'.
	</ul>

<h3 class=no-num id="changes-3">
Additions since CSS Level 2</h3>

	<p>In addition to substantially more detail
	to the various automatic and content-based sizing algorithms,
	the following new features have been added since [[CSS2]]:
	<ul>
		<li>The 'box-sizing' property (originally defined in [[CSS-UI-3]], then moved here).
		<li>The ''width/min-content'', ''width/max-content'', and ''width/fit-content()'' values of the [=sizing properties=].
		<li>The ''min-width/auto'' initial value of the 'min-width' and 'min-height' properties (originally defined in [[CSS-FLEXBOX-1]], then moved here).
	</ul>

<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>

	<p>Special thanks go to
	L. David Baron,
	Aaron Gustafson,
	Daniel Holbert,
	and
	Mats Palmgren
	for their contributions to this module.

<h2 class=no-num id="privacy">
Privacy Considerations</h2>

	In order to support automatic layout,
	CSS sizes boxes to fit their contents.
	In conjunction with various [[DOM]] and [[CSSOM]] APIs
	which can return the size of those boxes to script,
	this can expose information about those contents.
	However, this information is more directly and easily available
	by inspecting the DOM for the contents,
	rather than indirecting through the box’s size.
	Containers that can't have their contents inspected
	(such as cross-origin <{iframe}>s)
	also do not expose sizing information to the outer page,
	except insofar as [=replaced elements=] such as images
	expose their natural size and/or aspect ratio.

<h2 class=no-num id="security">
Security Considerations</h2>

No new security considerations have been reported on this specification.
